﻿using Shake.Framework.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Shake.Framework.Database;
using Shake.Framework.Repository;
using Shake.Business.Infrastructures;
using Shake.Domian.Filters;

namespace Shake.Business.Services
{
    public class LogService : ILogService
    {
        public IRepository Repository { get; set; }

        public PaginationContent GetLogs(PageArgument pageArg, LogFilter logFiler)
        {
            var query = Repository.Query<LogRecord>().AsQueryable();

            var results = query.OrderByDescending(t => t.LogAt).Page(pageArg);

            results.Filter = logFiler;

            return results;
        }
    }
}